<?php

namespace app\common\model\company;

use think\Model;

class CompanyTouchGood extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'companytouchgood';
    protected $pk    = 'Id';

    public function goodinfo()
    {
        return $this->hasOne('app\common\model\orderdata\Goods', 'GoodId', 'GoodId');
    }

    /**
     * 获取摸排表的危废信息
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public static function user_getlist($id){
        $data = CompanyTouchGood::where('CompanyTouchId',$id)->with('goodinfo');
        $data = $data->hidden(['goodinfo'=>['OperationLog','TotalWeight']])->select();
        foreach ($data as $key => $value) {
            if(!empty($value['goodinfo']['OrderNumber'])){
                $data[$key]['OrderNumber'] = $value['goodinfo']['OrderNumber'];
            }
        }
        return $data;
    }
}
